const { series, dest } = require('gulp');
const { createProject } = require('gulp-typescript');
const tscProj = createProject('./tsconfig.json');
const header = require("gulp-header");
const replace = require('gulp-replace');

/** 编译业务代码，并部署到所有的发布目录 */
function tsc(next) {
    let tscVinyl = tscProj.src()
        .pipe(tscProj())
    tscVinyl.js

        .pipe(replace('var wmedu;', ''))
        .pipe(header('var wmedu = window.wmedu = window.wmedu || {};'))
        .pipe(dest('./'))
    tscVinyl.dts
        .pipe(dest('./'));
    next();
}


exports.default = series(tsc); // code目录编译